/**
 * DiggApiNet - Digg API .NET Wrapper
 * 
 * Author: Sean Hickey
 * Link: http://www.headzoo.com/digg_api_net
 * License: GPL v2 ( http://www.gnu.org/licenses/gpl.txt )
 */
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Collections;

namespace DiggApiNet
{
    public class DiggTopics : DiggReturnBaseCollection
    {
        private List<DiggTopic> _topics;
        public List<DiggTopic> Topics
        {
            get
            {
                return _topics;
            }
            set
            {
                _topics = value;
            }
        }
        public DiggTopic this[int index]
        {
            get
            {
                return _topics[index];
            }
            set
            {
                _topics[index] = value;
            }
        }

        public DiggTopics()
        {
            _topics = new List<DiggTopic>();
        }
        public DiggTopics(XmlDocument xml_doc) : base(xml_doc, "topics")
        {
            _topics = new List<DiggTopic>();
            if (xml_doc.SelectSingleNode("topics") == null
                || xml_doc.SelectSingleNode("topics").SelectNodes("topic") == null) {
                throw new DiggApiException("XML response appears to be malformed, or contains unexpected data.");
            }
            foreach (XmlNode node in xml_doc.SelectSingleNode("topics").SelectNodes("topic")) {
                _topics.Add(new DiggTopic(node));
            }
        }

        public IEnumerator GetEnumerator()
        {
            return _topics.GetEnumerator();
        }
    }
}
